package com.taxshare.seller.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.taxshare.mybatis.entity.BaseEntity;
import com.taxshare.seller.constant.table.TableConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName: SellerMergeTemplateEntity
 * @Description:
 * @author: Hai
 * @date: 2021/7/2 13:55
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(TableConstant.T_SELLER_MERGE_TEMPLATE)
@ApiModel(description = "发票拆分规则模板")
public class SellerMergeTemplateEntity extends BaseEntity implements Serializable {

    @TableId("uuid")
    @ApiModelProperty("主键")
    private String uuid;

    @ApiModelProperty("模板名称")
    @TableField("template_name")
    private String templateName;

    @ApiModelProperty("货物或应税劳务list")
    @TableField("cargo_list")
    private String cargoList;

    @ApiModelProperty("创建时间")
    @TableField("create_time_str")
    private String createTimeStr;

    @ApiModelProperty("货物或应税劳务list")
    @TableField(exist = false)
    private List cargos;

    @ApiModelProperty("修改时间")
    @TableField("update_time_str")
    private String updateTimeStr;

    @ApiModelProperty("创建用户名字")
    @TableField("create_user_name")
    private String createUserName;

    public List getCargos() {
        if(this.cargoList != null && !this.cargoList.isEmpty()){
            cargos = Arrays.asList(this.cargoList);
        }
        return cargos;
    }

    public void setCargos(List cargos) {
        if(cargos != null && !cargos.isEmpty()){
            this.cargoList = cargos.toString();
        }
        this.cargos = cargos;
    }
}
